const Maybe = require("folktale/maybe");

/* const toRMB = (s) =>
  Maybe.of(s)
    .map((v) => v.replace("$", ""))
    .map(parseFloat)
    .map((v) => v * 7.5)
    .map((v) => v.toFixed(2))
    .map((v) => "¥" + v)
    .unsafeGet();

console.log(toRMB("$100")); */

const toRMB = (s) =>
  Maybe.fromNullable(s)
    .map((v) => v.replace("$", ""))
    .map(parseFloat)
    .map((v) => v * 7.5)
    .map((v) => v.toFixed(2))
    .map((v) => "¥" + v)
    .getOrElse("nothing");

console.log(toRMB("$100"), toRMB(null), toRMB());
